package com.eregg.learn.netty.protocol.client.handler;

import com.eregg.learn.netty.protocol.protocol.response.MessageResponsePacket;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

public class MessageResponseHandler extends SimpleChannelInboundHandler<MessageResponsePacket> {
    @Override
    protected void channelRead0(ChannelHandlerContext ctx, MessageResponsePacket messageResponsePacket) throws Exception {

        String fromUserId = messageResponsePacket.getFromUserId();
        String fromUsername = messageResponsePacket.getFromUsername();
        String message = messageResponsePacket.getMessage();

        System.out.println(String.format("[%s:%s] -> [%s]", fromUserId, fromUsername, message));
    }
}
